<!DOCTYPE html>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<meta name="Description" content="If you are only interested in the kernel, you may use this guide to download and build the appropriate kernel. The following instructions assume that you have not downloaded all of AOSP. If you have downloaded all of AOSP, you may skip the git clone steps…">

<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<title>Building Kernels | Android Developers</title>

<!-- STYLESHEETS -->
<link rel="stylesheet"
href="//fonts.googleapis.com/css?family=Roboto:regular,medium,thin,italic,mediumitalic,bold" title="roboto">
<link href="/assets/css/default.css" rel="stylesheet" type="text/css">



<!-- JAVASCRIPT -->
<script src="//www.google.com/jsapi" type="text/javascript"></script>
<script src="/assets/js/android_3p-bundle.js" type="text/javascript"></script>
<script type="text/javascript">
  var toRoot = "/";
  
  var devsite = false;
  
</script>
<script src="/assets/js/docs.js" type="text/javascript"></script>


<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-45455297-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>
</head>

<body class="gc-documentation 
  " itemscope itemtype="http://schema.org/Article">
<a name="top"></a>

  
    <!-- Header -->
    <div id="header">
        <div class="wrap" id="header-wrap">
          <div class="col-3 saclogo">
          <a href="/index.html">
            <img src="/assets/images/sac_logo.png"
                srcset="/assets/images/sac_logo@2x.png 2x"
                width="123" height="25" alt="Android Developers" />
          </a>
          </div>
            <ul class="nav-x col-9">
                <li class="source">
                  <a href="/source/index.html" class="selected"
                  >Source</a></li>
                <li class="devices"><a href="/devices/index.html" 
                  >Devices</a></li>
                <li class="accessories"><a href="/accessories/index.html" 
                  >Accessories</a></li>
                <li class="compatibility last"><a href="/compatibility/index.html" 
                  >Compatibility</a></li>
            </ul>
            <!-- New Search -->
            <div class="menu-container">
            <div class="moremenu">
    <div id="more-btn"></div>
  </div>
  <div class="morehover" id="moremenu">
    <div class="top"></div>
    <div class="mid">
      <div class="header">Android Sites</div>
      <ul>
        <li class="active"><a>Android Open Source Project</a></li>
        <li><a href="http://www.android.com">Android.com</a></li>
        <li><a href="http://developer.android.com">Android Developers</a></li>
      </ul>
      <!-- <div class="header">Support</div>
      <ul>
        <li><a href="/support.html">Developer Support</a></li>
      </ul> -->
      <br class="clearfix" />
    </div>
    <div class="bottom"></div>
  </div>

  <div class="search" id="search-container">
    <div class="search-inner">
      <div id="search-btn"></div>
      <div class="left"></div>
      <form onsubmit="return submit_search()">
        <input id="search_autocomplete" type="text" value="" autocomplete="off" name="q"
onfocus="search_focus_changed(this, true)" onblur="search_focus_changed(this, false)"
onkeydown="return search_changed(event, true, '/')"
onkeyup="return search_changed(event, false, '/')" />
      </form>
      <div class="right"></div>
        <a class="close hide">close</a>
        <div class="left"></div>
        <div class="right"></div>
    </div>
  </div>
  <div id="search_filtered_wrapper">
    <div id="search_filtered_div" class="no-display">
        <ul id="search_filtered">
        </ul>
    </div>
  </div>

  </div>
  <!-- /New Search> -->
        </div>
    </div>
    <!-- /Header -->

  <div id="searchResults" class="wrap" style="display:none;">
          <h2 id="searchTitle">Results</h2>
          <div id="leftSearchControl" class="search-control">Loading...</div>
  </div>

  
  
  
    
  <div class="wrap clearfix" id="body-content">
    <div class="col-4" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
      <div id="devdoc-nav" class="scroll-pane">
<a class="totop" href="#top" data-g-event="left-nav-top">to top</a>

<!--
    Copyright 2013 The Android Open Source Project

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<ul id="nav">
  <li class="nav-section">
    <div class="nav-section-header">
      <a href="/source/index.html">
        <span class="en">Overview</span>
      </a>
    </div>
    <ul>
      <li><a href="/source/code-lines.html">Codelines, Branches, and Releases</a></li>
      <li><a href="/source/build-numbers.html">Codenames, Tags, and Build Numbers</a></li>
      <li><a href="/source/roles.html">Project Roles</a></li>
      <li><a href="/source/brands.html">Brand Guidelines</a></li>
      <li><a href="/source/licenses.html">Licenses</a></li>
      <li><a href="/source/faqs.html">FAQ</a></li>
    </ul>
  </li>


  <li class="nav-section">
      <div class="nav-section-header">
        <a href="/source/building.html">
          <span class="en">Downloading and Building</span>
        </a>
      </div>
       <ul>
        <li><a href="/source/initializing.html">Initializing the Build Environment</a></li>
        <li><a href="/source/downloading.html">Downloading the Source</a></li>
        <li><a href="/source/building-running.html">Building and Running</a></li>
        <li><a href="/source/building-devices.html">Building for Devices</a></li>
        <li><a href="/source/building-kernels.html">Building Kernels</a></li>
        <li><a href="/source/64-bit-builds.html">64-bit Build Instructions</a></li>
        <li><a href="/source/known-issues.html">Known Issues</a></li>
      </ul>
  </li>
  <li class="nav-section">
          <div class="nav-section-header">
            <a href="/source/developing.html">
              <span class="en">Developing</span>
            </a>
          </div>
          <ul>
            <li><a href="/source/using-repo.html">Using Repo</a></li>
            <li><a href="/source/using-eclipse.html">Using Eclipse</a></li>
            <li><a href="/source/git-resources.html">Git Resources</a></li>
          </ul>
  </li>

  <li class="nav-section">
    <div class="nav-section-header">
      <a href="/source/contributing.html">
        <span class="en">Contributing</span>
      </a>
    </div>
       <ul>
        <li><a href="/source/life-of-a-patch.html">Life of a Patch</a>
        <li><a href="/source/submit-patches.html">Submitting Patches</a></li>
        <li><a href="http://android-review.googlesource.com">View Patches</a></li>
        <li><a href="/source/life-of-a-bug.html">Life of a Bug</a></li>
        <li><a href="/source/report-bugs.html">Reporting Bugs</a></li>
        <li><a href="/source/code-style.html">Code Style Guidelines</a></li>
      </ul>
  </li>

  <li class="nav-section">
    <div class="nav-section-header empty">
      <a href="/source/community/index.html">
        <span class="en">Community</span>
      </a>
    </div>
  </li>

</ul>


      </div>
    </div> <!-- end side-nav -->
    <script>
      $(document).ready(function() {
        scrollIntoView("devdoc-nav");
        });
    </script>

  




<div class="col-12" id="doc-col" >


  
    
      
        <h1 itemprop="name" >Building Kernels</h1>
      
    
  


  
  <div id="jd-content">


    <div class="jd-descr" itemprop="articleBody">
    <!--
    Copyright 2013 The Android Open Source Project

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<div id="qv-wrapper">
  <div id="qv">
    <h2>In this document</h2>
    <ol id="auto-toc">
    </ol>
  </div>
</div>

<p>If you are only interested in the kernel, you may use this guide
to download and build the appropriate kernel.</p>
<p>The following instructions assume that you have not downloaded all
of AOSP.  If you have downloaded all of AOSP, you may skip the git
clone steps other than the step to download the actual kernel sources.</p>
<p>We will use the Pandaboard kernel in all the following examples.</p>
<h2 id="figuring-out-which-kernel-to-build">Figuring out which kernel to build</h2>
<p>This table lists the name and locations of the kernel sources and binaries:
<table>
  <tr>
    <th>Device</th>
    <th>Binary location</th>
    <th>Source location</th>
    <th>Build configuration</th>
  </tr>
  <tr>
    <td>shamu</td>
    <td>device/moto/shamu-kernel</td>
    <td>kernel/msm</td>
    <td>shamu_defconfig</td>
  </tr>
  <tr>
    <td>fugu</td>
    <td>device/asus/fugu-kernel</td>
    <td>kernel/x86_64</td>
    <td>fugu_defconfig</td>
  </tr>
  <tr>
    <td>volantis</td>
    <td>device/htc/flounder-kernel</td>
    <td>kernel/tegra</td>
    <td>flounder_defconfig</td>
  </tr>
  <tr>
    <td>hammerhead</td>
    <td>device/lge/hammerhead-kernel</td>
    <td>kernel/msm</td>
    <td>hammerhead_defconfig</td>
  </tr>
  <tr>
    <td>flo</td>
    <td>device/asus/flo-kernel/kernel</td>
    <td>kernel/msm</td>
    <td>flo_defconfig</td>
  </tr>
  <tr>
    <td>deb</td>
    <td>device/asus/flo-kernel/kernel</td>
    <td>kernel/msm</td>
    <td>flo_defconfig</td>
  </tr>
  <tr>
    <td>manta</td>
    <td>device/samsung/manta/kernel</td>
    <td>kernel/exynos</td>
    <td>manta_defconfig</td>
  </tr>
  <tr>
    <td>mako</td>
    <td>device/lge/mako-kernel/kernel</td>
    <td>kernel/msm</td>
    <td>mako_defconfig</td>
  </tr>
  <tr>
    <td>grouper</td>
    <td>device/asus/grouper/kernel</td>
    <td>kernel/tegra</td>
    <td>tegra3_android_defconfig</td>
  </tr>
  <tr>
    <td>tilapia</td>
    <td>device/asus/grouper/kernel</td>
    <td>kernel/tegra</td>
    <td>tegra3_android_defconfig</td>
  </tr>
  <tr>
    <td>maguro</td>
    <td>device/samsung/tuna/kernel</td>
    <td>kernel/omap</td>
    <td>tuna_defconfig</td>
  </tr>
  <tr>
    <td>toro</td>
    <td>device/samsung/tuna/kernel</td>
    <td>kernel/omap</td>
    <td>tuna_defconfig</td>
  </tr>
  <tr>
    <td>panda</td>
    <td>device/ti/panda/kernel</td>
    <td>kernel/omap</td>
    <td>panda_defconfig</td>
  </tr>
  <tr>
    <td>stingray</td>
    <td>device/moto/wingray/kernel</td>
    <td>kernel/tegra</td>
    <td>stingray_defconfig</td>
  </tr>
  <tr>
    <td>wingray</td>
    <td>device/moto/wingray/kernel </td>
    <td>kernel/tegra</td>
    <td>stingray_defconfig</td>
  </tr>
  <tr>
    <td>crespo</td>
    <td>device/samsung/crespo/kernel</td>
    <td>kernel/samsung</td>
    <td>herring_defconfig</td>
  </tr>
  <tr>
    <td>crespo4g</td>
    <td>device/samsung/crespo/kernel</td>
    <td>kernel/samsung</td>
    <td>herring_defconfig</td>
  </tr>
</table>

<p>You will want to look at the git log for the kernel binary in the device
project that you are interested in.</p>

<p>Device projects are of the form device/&lt;vendor&gt;/&lt;name&gt;.</p>
<pre><code>$ git clone https://android.googlesource.com/device/ti/panda
$ cd panda
$ git log --max-count=1 kernel
</code></pre>

<p>The commit message for the kernel binary contains a partial git log
of the kernel sources that were used to build the binary in question.
The first entry in the log is the most recent, i.e. the one used to
build that kernel. You will need it at a later step.</p>


<h2 id="id-version">Identifying kernel version</h2>
<p>To determine the kernel version used in a particular system image, run the
following command against the kernel file:</p>
<pre><code>
$ dd if=kernel bs=1 skip=$(LC_ALL=C grep -a -b -o $'\x1f\x8b\x08\x00\x00\x00\x00\x00' kernel | cut -d ':' -f 1) | zgrep -a 'Linux version'
</code></pre>
<p>For Nexus 5 (hammerhead), this can be accomplished with:</p>
<pre><code>
$ dd if=zImage-dtb bs=1 skip=$(LC_ALL=C od -Ad -x -w2 zImage-dtb | grep 8b1f | cut -d ' ' -f1 | head -1) | zgrep -a 'Linux version'
</code></pre>


<h2 id="downloading-sources">Downloading sources</h2>
<p>Depending on which kernel you want,</p>
<pre><code>$ git clone https://android.googlesource.com/kernel/common.git
$ git clone https://android.googlesource.com/kernel/x86_64.git
$ git clone https://android.googlesource.com/kernel/exynos.git
$ git clone https://android.googlesource.com/kernel/goldfish.git
$ git clone https://android.googlesource.com/kernel/msm.git
$ git clone https://android.googlesource.com/kernel/omap.git
$ git clone https://android.googlesource.com/kernel/samsung.git
$ git clone https://android.googlesource.com/kernel/tegra.git
</code></pre>
<ul>
<li>The <code>goldfish</code> project contains the kernel sources for the emulated
platforms.</li>
<li>The <code>msm</code> project has the sources for ADP1, ADP2, Nexus One, Nexus 4, Nexus 5, Nexus 6,
and can be used as a starting point for work on Qualcomm MSM chipsets.</li>
<li>The <code>omap</code> project is used for PandaBoard and Galaxy Nexus,
and can be used as a starting point for work on TI OMAP chipsets.</li>
<li>The <code>samsung</code> project is used for Nexus S,
and can be used as a starting point for work on Samsung Hummingbird chipsets.</li>
<li>The <code>tegra</code> project is for Xoom, Nexus 7, Nexus 9,
and can be used as a starting point for work on NVIDIA Tegra chipsets.</li>
<li>The <code>exynos</code> project has the kernel sources for Nexus 10,
and can be used as a starting point for work on Samsung Exynos chipsets.</li>
<li>The <code>x86_64</code> project has the kernel sources for Nexus Player,
and can be used as a starting point for work on Intel x86_64 chipsets.</li>
</ul>
<h2 id="downloading-a-prebuilt-gcc">Downloading a prebuilt gcc</h2>
<p>Ensure that the prebuilt toolchain is in your path.</p>
<pre>$ export PATH=$(pwd)/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin:$PATH</pre>

or
<pre>$ export PATH=$(pwd)/prebuilts/gcc/darwin-x86/arm/arm-eabi-4.6/bin:$PATH</pre>

<p>On a linux host, if you don't have an Android source tree, you can download
the prebuilt toolchain from:
<pre>$ git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6</pre>

<h2 id="building">Building</h2>
<p>As an example, we would build the panda kernel using the following commands:</p>
<pre><code>$ export ARCH=arm
$ export SUBARCH=arm
$ export CROSS_COMPILE=arm-eabi-
$ cd omap
$ git checkout &lt;commit_from_first_step&gt;
$ make panda_defconfig
$ make
</code></pre>
<p>To build the tuna kernel, you may run the previous commands replacing all
instances of "panda" with "tuna".</p>
<p>
The kernel binary is output as: `arch/arm/boot/zImage` It can be copied
into the Android source tree in order to build the matching boot image.
</p>
<p>Or you can include the <code>TARGET_PREBUILT_KERNEL</code> variable while
using <code>make bootimage</code> or any other make command line that builds a
boot image.</p>
<pre><code>
$ export TARGET_PREBUILT_KERNEL=$your_kernel_path/arch/arm/boot/zImage
</code></pre>
<p>That variable is supported by all devices as it is set up via
device/common/populate-new-device.sh</p>

    </div>
      
      <div class="content-footer layout-content-row" 
                    itemscope itemtype="http://schema.org/SiteNavigationElement">
        <div class="layout-content-col col-9" style="padding-top:4px">
          
            <div class="g-plusone" data-size="medium"></div>
          
        </div>
        
        <div class="paging-links layout-content-col col-4">
          
        </div>
        
      </div>
      
      
      

  </div> <!-- end jd-content -->

<div id="footer" class="wrap" >
  <div id="copyright">
    
  Except as noted, this content is 
  licensed under <a href="http://creativecommons.org/licenses/by/2.5/">
  Creative Commons Attribution 2.5</a>. For details and 
  restrictions, see the <a href="/license.html">Content 
  License</a>.
  </div>
    <div id="footerlinks">
    
  <p>
    <a href="/source/index.html">About Android</a>&nbsp;&nbsp;|&nbsp;
    <a href="/source/community/index.html">Community</a>&nbsp;&nbsp;|&nbsp;
    <a href="/legal.html">Legal</a>&nbsp;&nbsp;|&nbsp;
  </p>
  </div>

</div><!-- end doc-content -->

</div> <!-- end body-content --> 






</body>
</html>



